/datum/damage
	var/brute = 0
	var/burn = 0
	var/toxin = 0
	var/electric = 0
	var/suffocation = 0
	var/total = 0

/datum/damage/New(brute, burn, toxin, electric, suffocation)
	if(brute)
		src.brute = brute
	if(burn)
		src.burn = burn
	if(toxin)
		src.toxin = toxin
	if(electric)
		src.electric = electric
	if(suffocation)
		src.suffocation = suffocation
	total()

/datum/damage/proc/add(datum/damage/dam)
	if(dam.brute)
		src.brute += max(dam.brute, 0)
	if(dam.burn)
		src.burn += max(dam.burn, 0)
	if(dam.toxin)
		src.toxin += max(dam.toxin, 0)
	if(dam.electric)
		src.electric += max(dam.electric, 0)
	if(dam.suffocation)
		src.suffocation += max(dam.suffocation, 0)
	total()

/datum/damage/proc/subtract(datum/damage/dam)
	//returns anything left over from the subtraction, doesn't just throw away overflow
	if(dam.brute > src.brute)
		dam.brute -= src.brute
		src.brute = 0
	else
		src.brute -= dam.brute
		dam.brute = 0

	if(dam.burn > src.burn)
		dam.burn -= src.burn
		src.burn = 0
	else
		src.burn -= dam.burn
		dam.burn = 0

	if(dam.toxin > src.toxin)
		dam.toxin -= src.toxin
		src.toxin = 0
	else
		src.toxin -= dam.toxin
		dam.toxin = 0

	if(dam.electric > src.electric)
		dam.electric -= src.electric
		src.electric = 0
	else
		src.electric -= dam.electric
		dam.electric = 0

	if(dam.suffocation > src.suffocation)
		dam.suffocation -= src.suffocation
		src.suffocation = 0
	else
		src.suffocation -= dam.suffocation
		dam.suffocation = 0
	total()

	dam.total()
	if(dam.total)
		return dam
	else
		return null

/datum/damage/proc/total()
	src.total = src.brute + src.burn + src.toxin + src.electric + src.suffocation
